<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - find_optimal_parameters.cpp</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2008  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font>

<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>optimization<font color='#5555FF'>/</font>find_optimal_parameters.h<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='tester.h.html'>tester.h</a>"


<font color='#0000FF'>namespace</font>  
<b>{</b>

    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> test;
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> dlib;
    <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;

    logger <b><a name='dlog'></a>dlog</b><font face='Lucida Console'>(</font>"<font color='#CC0000'>test.find_optimal_parameters</font>"<font face='Lucida Console'>)</font>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>

    <font color='#0000FF'>class</font> <b><a name='find_optimal_parameters'></a>find_optimal_parameters</b> : <font color='#0000FF'>public</font> tester
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <b><a name='find_optimal_parameters'></a>find_optimal_parameters</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> :
            tester <font face='Lucida Console'>(</font>"<font color='#CC0000'>test_find_optimal_parameters</font>",
                    "<font color='#CC0000'>Runs tests on find_optimal_parameters().</font>"<font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='perform_test'></a>perform_test</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>print_spinner</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> params <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0.5</font>, <font color='#979000'>0.5</font><b>}</b>;
            dlib::<font color='#BB00BB'>find_optimal_parameters</font><font face='Lucida Console'>(</font><font color='#979000'>4</font>, <font color='#979000'>0.001</font>, <font color='#979000'>100</font>, params, <b>{</b><font color='#5555FF'>-</font><font color='#979000'>0.1</font>, <font color='#5555FF'>-</font><font color='#979000'>0.01</font><b>}</b>, <b>{</b><font color='#979000'>5</font>, <font color='#979000'>5</font><b>}</b>, []<font face='Lucida Console'>(</font><font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> params<font face='Lucida Console'>)</font> <b>{</b>
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>.</font>";
                <font color='#0000FF'>return</font> <font color='#BB00BB'>sum</font><font face='Lucida Console'>(</font><font color='#BB00BB'>squared</font><font face='Lucida Console'>(</font>params<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b><font face='Lucida Console'>)</font>;

            matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font> true_params <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0</font>,<font color='#979000'>0</font><b>}</b>;

            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_params <font color='#5555FF'>-</font> params<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>10</font><font face='Lucida Console'>)</font>;

            params <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0.1</font><b>}</b>;
            dlib::<font color='#BB00BB'>find_optimal_parameters</font><font face='Lucida Console'>(</font><font color='#979000'>4</font>, <font color='#979000'>0.001</font>, <font color='#979000'>100</font>, params, <b>{</b><font color='#5555FF'>-</font><font color='#979000'>0.01</font><b>}</b>, <b>{</b><font color='#979000'>5</font><b>}</b>, []<font face='Lucida Console'>(</font><font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>1</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> params<font face='Lucida Console'>)</font> <b>{</b>
                cout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>.</font>";
                <font color='#0000FF'>return</font> <font color='#BB00BB'>sum</font><font face='Lucida Console'>(</font><font color='#BB00BB'>squared</font><font face='Lucida Console'>(</font>params<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <b>}</b><font face='Lucida Console'>)</font>;

            true_params <font color='#5555FF'>=</font> <b>{</b><font color='#979000'>0</font><b>}</b>;
            <font color='#BB00BB'>DLIB_TEST</font><font face='Lucida Console'>(</font><font color='#BB00BB'>max</font><font face='Lucida Console'>(</font><font color='#BB00BB'>abs</font><font face='Lucida Console'>(</font>true_params <font color='#5555FF'>-</font> params<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font> <font color='#979000'>1e</font><font color='#5555FF'>-</font><font color='#979000'>10</font><font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b> a;

<b>}</b>




</pre></body></html>